package com.gs.api.projects.shejiao.web;


import com.gs.api.core.Result;
import com.gs.api.projects.shejiao.service.IBalanceRecordService;
import com.gs.api.projects.shejiao.vo.BalanceRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 余额记录表 前端控制器
 * </p>
 *
 * @author guoshao
 * @since 2021-10-15
 */
@Api(tags = "收入支出信息")
@RestController
@RequestMapping("{appid}/balance")
public class BalanceRecordController {

    @Autowired
    private IBalanceRecordService iBalanceRecordService;


    @ApiOperation(value = "收入支出列表", notes="收入支出列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "offset", value = "offset", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "openid", value = "用户微信openid", required = true, dataType = "String"),
            @ApiImplicitParam(name = "appid", value = "小程序appid", required = true, dataType = "String"),
            @ApiImplicitParam(name = "dataType", value = "dataType", required = true, dataType = "String"),
    })
    @GetMapping("/list")
    private Result getBalanceRecord(@PathVariable String appid, Integer offset,String openid,Integer dataType){


        /*IPage<BalanceRecord> records = new Page<>(pageNum, Constant.PAGESIZE);//参数一是当前页，参数二是每页个数

        IPage<BalanceRecord> page = balanceRecordMapper.selectPage(records,
                new QueryWrapper<BalanceRecord>().eq("user_id", openid)
        .eq("data_type",dataType).orderByDesc("create_time"));
        List<BalanceRecord> list = page.getRecords();*/

        Map<String,Object> map = new HashMap<>();
        map.put("userId",openid);
        map.put("dataType",dataType);
        List<BalanceRecordVo> list = iBalanceRecordService.selectMyList(map, offset);

        return Result.success(list);
    }

}
